package geekstudy.week6;

/**
 * 70. 爬楼梯
 * https://leetcode-cn.com/problems/climbing-stairs/submissions/
 *
 *
 * 执行结果：  通过  显示详情
 *
 * 添加备注
 * 执行用时：0 ms, 在所有 Java 提交中击败了100.00% 的用户
 * 内存消耗：35.1 MB, 在所有 Java 提交中击败了57.30% 的用户
 *
 */
public class Week6ClimbingStairs {

    public int climbStairs(int n) {
        if(n<=2){
            return n;
        }
        int first = 1;
        int second =2;
        for(int size = 3; size <= n; size++){
            second = first + second;
            first = second - first;
        }
        return second;
    }
}
